package com.carepulse.query;

import org.jruby.Ruby;
import org.jruby.RubyObject;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.javasupport.JavaUtil;
import org.jruby.RubyClass;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletContext;


public class RubyQueryService extends RubyObject  {
    private static final Ruby __ruby__ = Ruby.getGlobalRuntime();
    private static final RubyClass __metaclass__;

    static {
        __ruby__.getLoadService().require("rubysrc/irubyservice");
        __ruby__.getLoadService().require("rubysrc/libs/query");
        RubyClass metaclass = __ruby__.getClass("RubyQueryService");
        if (metaclass == null) throw new NoClassDefFoundError("Could not load Ruby class: RubyQueryService");
        metaclass.setRubyStaticAllocator(RubyQueryService.class);
        __metaclass__ = metaclass;
    }

    /**
     * Standard Ruby object constructor, for construction-from-Ruby purposes.
     * Generally not for user consumption.
     *
     * @param ruby The JRuby instance this object will belong to
     * @param metaclass The RubyClass representing the Ruby class of this object
     */
    private RubyQueryService(Ruby ruby, RubyClass metaclass) {
        super(ruby, metaclass);
    }

    /**
     * A static method used by JRuby for allocating instances of this object
     * from Ruby. Generally not for user comsumption.
     *
     * @param ruby The JRuby instance this object will belong to
     * @param metaclass The RubyClass representing the Ruby class of this object
     */
    public static IRubyObject __allocate__(Ruby ruby, RubyClass metaClass) {
        return new RubyQueryService(ruby, metaClass);
    }


    
    public static void init_service(String dbconfig_path) {
        IRubyObject ruby_arg_dbconfig_path = JavaUtil.convertJavaToRuby(__ruby__, dbconfig_path);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), __metaclass__, "init_service", ruby_arg_dbconfig_path);
        return;

    }

    
    public  RubyQueryService(ServletContext servletctx) {
        this(__ruby__, __metaclass__);
        IRubyObject ruby_arg_servletctx = JavaUtil.convertJavaToRuby(__ruby__, servletctx);
        Helpers.invoke(__ruby__.getCurrentContext(), this, "initialize", ruby_arg_servletctx);

    }

    
    public void doGet(HttpServletRequest req, HttpServletResponse res) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_arg_res = JavaUtil.convertJavaToRuby(__ruby__, res);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "doGet", ruby_arg_req, ruby_arg_res);
        return;

    }

    
    public void doPut(HttpServletRequest req, HttpServletResponse res) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_arg_res = JavaUtil.convertJavaToRuby(__ruby__, res);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "doPut", ruby_arg_req, ruby_arg_res);
        return;

    }

    
    public void doPost(HttpServletRequest req, HttpServletResponse res) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_arg_res = JavaUtil.convertJavaToRuby(__ruby__, res);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "doPost", ruby_arg_req, ruby_arg_res);
        return;

    }

    
    public void doDelete(HttpServletRequest req, HttpServletResponse res) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_arg_res = JavaUtil.convertJavaToRuby(__ruby__, res);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "doDelete", ruby_arg_req, ruby_arg_res);
        return;

    }

    
    public Object params(Object req) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "params", ruby_arg_req);
        return (Object)ruby_result.toJava(Object.class);

    }

    
    public Object data(Object req) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "data", ruby_arg_req);
        return (Object)ruby_result.toJava(Object.class);

    }

    
    public Object parse_url(Object req) {
        IRubyObject ruby_arg_req = JavaUtil.convertJavaToRuby(__ruby__, req);
        IRubyObject ruby_result = Helpers.invoke(__ruby__.getCurrentContext(), this, "parse_url", ruby_arg_req);
        return (Object)ruby_result.toJava(Object.class);

    }

}
